﻿CREATE PROCEDURE [acms].[Post_GetAllByParentGuid]
	@ParentGuid UniqueIdentifier, 
	@SiteVersion DateTime
AS
	declare @tmp datetime
	set @tmp = acms.GetPublishDate(@SiteVersion)
	
	if(@tmp is null and @SiteVersion is not null)
		return

	SELECT a.*, b.[ParentPath] as ParentPath, b.PublishDate as SiteVersion
	FROM [Post_View] a
		inner join PostPositions b on a.Id = b.PostId and isnull(b.PublishDate, '9999/12/31') = isnull(@tmp, '9999/12/31')
	Where ParentGuid = @ParentGuid
	ORDER By Sequence
RETURN 0;